<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\file\FileInput;//图片上传
use dosamigos\datetimepicker\DateTimePicker;//时间
use \kucha\ueditor\UEditor;
use common\models\meeting\Meeting;
use common\models\category\Category;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $model common\models\meeting\Meeting */
/* @var $form yii\widgets\ActiveForm */
?>
<style>
 .kv-file-content img{ width: 100%!important; }
 </style>
<div class="meeting-form">

    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'],'id'=>'subform']); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'category_id')->label('分类')->dropDownList(ArrayHelper::map(Category::get(0, Category::find()->where(['status'=>1])->asArray()->all()), 'id', 'str_label')) ?>

    <?= $form->field($model, 'summary')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'content')->widget('kucha\ueditor\UEditor',[]) ?>

    <?php
            if(isset(json_decode($model->label_img)->newname)){
                $img = json_decode($model->label_img)->newname;
            }else{
                $img = $model->label_img;
            }
            $siteRoot = Yii::$app->params['qtimg'];
            echo '<label class="control-label">会场平面图</label>';
            echo FileInput::widget([
                'model' => $model,
                'attribute' => 'label_img',
                'options' => ['accept' => 'image/*'],
                'pluginOptions' => [
                    'uploadExtraData' => [
                        'album_id' => 20,
                        'cat_id' => 'Nature'
                    ],
                    'initialPreview'=>[
                        !empty($img)?Html::img(Yii::$app->params['qtimg'].$img):null,
                    ],
                    'initialCaption'=> $img,
                    'maxFileCount' => 10,
                    "showUpload"=> false,
                ]
            ]);
    ?>
    
    <?= $form->field($model, 'schedule')->widget('kucha\ueditor\UEditor',[]) ?>

    <?= $form->field($model, 'beforeprompt')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'duringprompt')->textInput(['maxlength' => true]) ?>

        <?php
            if(isset(json_decode($model->meetingdata)->oldname)){
                $img = json_decode($model->meetingdata)->oldname;
            }else{
                $img = $model->meetingdata;
            }
            $siteRoot = Yii::$app->params['qtimg'];
            echo '<label class="control-label">会议资料</label>;';
            echo FileInput::widget([
                'model' => $model,
                'attribute' => 'meetingdata',
                'options' => ['accept' => 'file/*'],
                'pluginOptions' => [
                    'uploadExtraData' => [
                        'album_id' => 20,
                        'cat_id' => 'Nature'
                    ],
                    'initialCaption'=> $img,
                    'maxFileCount' => 10,
                    "showUpload"=> false,
                ]
            ]);
    ?>

    <div>
        <div class="form-group field-classteam-starttime required" style="width: 300px">
            <label class="control-label" for="classteam-starttime">开始时间</label>
            <?= DateTimePicker::widget([
                'model' => $model,
                'attribute' => 'starttime',
                'language' => 'zh-CN',
                'size' => 'ms',
                'clientOptions' => [
                    'autoclose' => true,
                    'linkFormat' => 'yyyy-mm-dd  HH:ii ',
                    'todayBtn' => true
                ]
            ]);?>
        </div>
    </div>
	<div>
        <div class="form-group field-classteam-starttime required" style="width: 300px">
            <label class="control-label" for="classteam-starttime">结束时间</label>
            <?= DateTimePicker::widget([
                'model' => $model,
                'attribute' => 'endtime',
                'language' => 'zh-CN',
                'size' => 'ms',
                'clientOptions' => [
                    'autoclose' => true,
                    'linkFormat' => 'yyyy-mm-dd  HH:ii ',
                    'todayBtn' => true
                ]
            ]);?>
        </div>
    </div>
    <div>
        <div class="form-group field-classteam-starttime required" style="width: 300px">
            <label class="control-label" for="classteam-starttime">报名截止时间</label>
            <?= DateTimePicker::widget([
                'model' => $model,
                'attribute' => 'deadline',
                'language' => 'zh-CN',
                'size' => 'ms',
                'clientOptions' => [
                    'autoclose' => true,
                    'linkFormat' => 'yyyy-mm-dd  HH:ii ',
                    'todayBtn' => true
                ]
            ]);?>
        </div>
    </div>

	<?= $form->field($model, 'enroll')->dropDownList(Meeting::getArrayIsopen()) ?>
	<?= $form->field($model, 'is_pay')->dropDownList(Meeting::getArrayIspay()) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
